package cn.zh.stan;

import android.app.Application;
import android.content.Context;
import android.content.SharedPreferences;
import android.util.Log;

import com.alibaba.sdk.android.push.CloudPushService;
import com.alibaba.sdk.android.push.CommonCallback;
import com.alibaba.sdk.android.push.noonesdk.PushServiceFactory;
import com.lzy.okhttputils.OkHttpUtils;
import com.pgyersdk.crash.PgyCrashManager;
import com.pgyersdk.update.PgyUpdateManager;

import cn.zh.stan.ITem.CityTem;
import cn.zh.stan.ITem.UserItem;
import cn.zh.stan.util.CityListLoader;

/**
 * Created by WYN on 2018/1/15 0015.
 */

public class MyApplication extends Application {

    SharedPreferences sp;

    UserItem userItem=null;
    String headurl="";

    CityTem  proviece,cityitem,areaim;

    boolean iscity=false;
    //判断哪个activity选择城市
    int arechose=1;
    boolean ischose=true;
     //判断支付宝是否支付成功
    boolean ispay=true;

    private static final String TAG = "Init";
    @Override
    public void onCreate() {
        super.onCreate();
        OkHttpUtils.init(this);
        sp=getSharedPreferences("sp",MODE_PRIVATE);
        CityListLoader.getInstance().loadProData(this);
        initCloudChannel(this);
        PgyUpdateManager.setIsForced(false);
        PgyCrashManager.register(this);
        }

    /**
     * 初始化云推送通道
     * @param applicationContext
     */
    private void initCloudChannel(Context applicationContext) {
        PushServiceFactory.init(applicationContext);
        CloudPushService pushService = PushServiceFactory.getCloudPushService();
        pushService.register(applicationContext, new CommonCallback() {
            @Override
            public void onSuccess(String response) {
             }
            @Override
            public void onFailed(String errorCode, String errorMessage) {
            }
           });
        }




    public SharedPreferences getSp() {
        return sp;
    }

    public UserItem getUserItem() {
        return userItem;
    }

    public void setUserItem(UserItem userItem) {
        this.userItem = userItem;
    }

    public String getHeadurl() {
        return headurl;
    }

    public void setHeadurl(String headurl) {
        this.headurl = headurl;
    }

    public CityTem getProviece() {
        return proviece;
    }

    public void setProviece(CityTem proviece) {
        this.proviece = proviece;
    }

    public CityTem getCityitem() {
        return cityitem;
    }

    public void setCityitem(CityTem cityitem) {
        this.cityitem = cityitem;
    }

    public CityTem getAreaim() {
        return areaim;
    }

    public void setAreaim(CityTem areaim) {
        this.areaim = areaim;
    }

    public boolean isIscity() {
        return iscity;
    }

    public void setIscity(boolean iscity) {
        this.iscity = iscity;
    }

    public boolean isIschose() {
        return ischose;
    }

    public void setIschose(boolean ischose) {
        this.ischose = ischose;
    }

    public boolean isIspay() {
        return ispay;
    }

    public void setIspay(boolean ispay) {
        this.ispay = ispay;
    }

    public int getArechose() {
        return arechose;
      }

    public void setArechose(int arechose) {
        this.arechose = arechose;
    }
}
